﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using MR_HKSUtility;

namespace MR_HKSLaplacian
{
    /**
     * Multimedia Retrieval
     * Heat Kernel Signature project
     * Frank Borgonjen, Joeri van der Lei & Kevin van der Lei
     * 28-10-2011
     * 
     * The LaplacianSaver class uses the OffReader utility class to process .off files and generate Laplacian 
     * matrix files that can be used to calculate the heat kernel signature values.
     */
    class LaplacianSaver
    {
        #region Functions

        /**
         * The main method takes the given directory name and processes all .off files in that
         * directory.
         */
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                // Loop over directory and process the list of files found.
                string[] fileEntries = Directory.GetFiles(args[0]);
                foreach (string fileName in fileEntries)
                {
                    //check if the file is an .off file
                    if (fileName.ToLower().EndsWith(".off"))
                    {
                        OffReader myOffReader;
                        myOffReader = new OffReader(fileName);
                        myOffReader.ReadFile();
                        myOffReader.LaplacianToFile();
                    }
                }
            }
            else
                Console.WriteLine("No directory name given.");
        }

        #endregion
    }
}
